package com.lottery.ruok.lottrey.dialog;

import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;

import com.lottery.ruok.lottrey.R;
import com.lottery.ruok.lottrey.dialog.base.BaseDialog;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;

public class ActivitiesFilterDialog extends BaseDialog implements View.OnClickListener {
    @BindView(R.id.tv_underway)
    TextView tvUnderway;
    @BindView(R.id.tv_overdue)
    TextView tvOverdue;
    @BindView(R.id.tv_all)
    TextView tvAll;
    @BindView(R.id.tv_cancel)
    TextView tvCancel;
    Unbinder unbinder;
    private ActivitiesFilterDialogAllListenerCallback callback;

    public void setCallback(ActivitiesFilterDialogAllListenerCallback callback) {
        this.callback = callback;
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activities_filter_dialog_layout;
    }

    @Override
    protected void initView(View view) {
        tvUnderway.setOnClickListener(this);
        tvOverdue.setOnClickListener(this);
        tvAll.setOnClickListener(this);
        tvCancel.setOnClickListener(this);
        this.getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
        Window window = this.getDialog().getWindow();
        WindowManager.LayoutParams lp = window.getAttributes();
        //设置dialog的位置在底部
        lp.gravity = Gravity.BOTTOM;
        //设置dialog的动画
        lp.windowAnimations = R.style.BottomDialogAnimation;
        window.setAttributes(lp);
        setCancelable(false);
        setCanceledOnTouchOutside(false);
    }

    @Override
    protected void loadData(Bundle bundle) {

    }

    @Override
    public void onClick(View v) {
        if (callback == null) return;
        switch (v.getId()) {
            case R.id.tv_underway:
                callback.onClickUnderway(v);
                break;
            case R.id.tv_overdue:
                callback.onClickOverdue(v);
                break;
            case R.id.tv_all:
                callback.onClickAll(v);
                break;
            case R.id.tv_cancel:
                callback.onClickCancel(v);
                break;
        }
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        // TODO: inflate a fragment view
        View rootView = super.onCreateView(inflater, container, savedInstanceState);
        unbinder = ButterKnife.bind(this, rootView);
        return rootView;
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }

    public interface ActivitiesFilterDialogAllListenerCallback {
        void onClickUnderway(View view);

        void onClickOverdue(View view);

        void onClickAll(View view);

        void onClickCancel(View view);
    }
}
